import { createRouter, createWebHistory } from 'vue-router'
// import Router from 'vue-router'

//createRouter：创建路由对象
const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),   //路由规则模式
    //路由的规则设置
    routes: [
        {
            path: '/login',    //地址路径
            name: '用户登陆',
            component: () => import("@/views/login.vue")   //映射的文件路径
        },
        {
            path: '/',
            name: '/Framework',
            component: () => import("@/views/Framework.vue"),
            children: [
                {
                    path: '/',
                    redirect: "/main/all"
                },
                {
                    path: '/main/:category',
                    name: '首页',
                    meta: {
                        needLogin: true,
                        menuCode: "main"
                    },
                    component: () => import("@/views/main/Main.vue")
                },
                {
                    path: '/myshare',
                    name: '我的分享',
                    meta: {
                        needLogin: true,
                        menuCode: "share"
                    },
                    component: () => import("@/views/share/Share.vue")
                },
                {
                    path: '/recycle',
                    name: '回收站',
                    meta: {
                        needLogin: true,
                        menuCode: "recycle"
                    },
                    component: () => import("@/views/recycle/Recycle.vue")
                },
                {
                    path: '/settings/sysSetting',
                    name: '系统设置',
                    meta: {
                        needLogin: true,
                        menuCode: "settings"
                    },
                    component: () => import("@/views/admin/SysSettings.vue")
                },
                {
                    path: '/settings/userList',
                    name: '用户管理',
                    meta: {
                        needLogin: true,
                        menuCode: "settings"
                    },
                    component: () => import("@/views/admin/userList.vue")
                },
                {
                    path: '/settings/fileList',
                    name: '用户文件',
                    meta: {
                        needLogin: true,
                        menuCode: "settings"
                    },
                    component: () => import("@/views/admin/FileList.vue")
                },
            ]
        }
    ]
})

// export const constantRoutes = [
//     {
//         path: '/',
//         name: 'login',
//         component: () => import('@/views/login')
//     }
// ]

// const createRouter = () => new Router({
//     scrollBehavior: () => ({ y: 0 }),
//     routes: constantRoutes
// })

// const router = createRouter()

// export function resetRouter() {
//     const newRouter = createRouter()
//     router.matcher = newRouter.matcher
// }

export default router